﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.IO;
using Medianamik.Core.Configuration;
using Medianamik.Core;

namespace Medianamik.UI.Web.TypeManagement.Controls
{
    public partial class TemplatePicker : System.Web.UI.UserControl
    {
        internal const string MissingPageTemplateWarningMessage = "!!! Gabarit de page manquant / Missing PageTemplate !!!";
        protected internal void Page_Load(object sender, EventArgs e)
        {
            if (Template.Template == null)
            {
                TemplateName = MissingPageTemplateWarningMessage;
            }
            else
            {
                TemplateName = String.Concat(Template.WebSite.DisplayName,
                                             " --> ", Template.Template.DisplayName);
            }
        }

        public event EventHandler RemoveTemplate;

        protected void btnRemoveTemplate_Click(object sender, EventArgs e)
        {
            if (RemoveTemplate != null)
            {
                RemoveTemplate(this, e);
            }
        }

        protected internal virtual string TemplateName
        {
            get
            {
                return litTemplate.Text;
            }
            set
            {
                litTemplate.Text = value;
            }
        }

        public virtual TypeTemplate Template
        {
            get
            {
                return (TypeTemplate)ViewState["Template"];
            }
            set
            {
                ViewState["Template"] = value;
            }
        }
    }
}